package com.bee.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bee.user.common.domain.ResourceDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author Damin.yang
 * @date 2019/08/18 17:19
 */
@Mapper
public interface ResourceMapper extends BaseMapper<ResourceDO> {

    String COLUMN = "id, `name`, code, `type`, parent_id, service_id, url, sort, `status`, " +
            " create_time, creator, update_time, updator, delete_time";

    /**
     * 查询所有
     * @return
     */
    @Select("select " + COLUMN + " from resource")
    List<ResourceDO> queryAll();

    @Select("select " + COLUMN + " from resource where deleted = 0 and id in (select id from resource_id where role_id = #{roleId})")
    List<ResourceDO> queryByRoleId(@Param("roleId") Long roleId);
}
